import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '脚本名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '文件名',
    align: 'center',
    dataIndex: 'fileName',
  },
  {
    title: '脚本描述',
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: '脚本图标',
    align: 'center',
    dataIndex: 'icon',
  },
  {
    title: '脚本颜色',
    align: 'center',
    dataIndex: 'color',
  },
  {
    title: '脚本状态',
    align: 'center',
    dataIndex: 'status',
  },
  {
    title: '查看次数',
    align: 'center',
    dataIndex: 'viewCount',
  },
  {
    title: '排序权重',
    align: 'center',
    dataIndex: 'sortOrder',
  },
  {
    title: '创建人',
    align: 'center',
    dataIndex: 'createBy_dictText',
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'createTime',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '脚本名称',
    field: 'name',
    component: 'JInput',
    colProps: { span: 4 },
  },
  {
    label: '文件名',
    field: 'fileName',
    component: 'JInput',
    colProps: { span: 4 },
  },
  {
    label: '脚本描述',
    field: 'description',
    component: 'JInput',
    colProps: { span: 4 },
  },
  {
    label: '脚本状态',
    field: 'status',
    component: 'RadioGroup',
    componentProps: {
      options: [
        { label: '激活', value: 'active' },
        { label: '禁用', value: 'inactive' },
        { label: '草稿', value: 'draft' },
      ],
      // 你也可以用optionType: 'button'让它变成按钮风格
      optionType: 'button',
      buttonStyle: 'solid',
    },
    colProps: { span: 5 },
    defaultValue: 'active',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '脚本名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入脚本名称!' }];
    },
  },
  {
    label: '文件名',
    field: 'fileName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入文件名!' }];
    },
  },
  {
    label: '文件大小(字节)',
    field: 'fileSize',
    component: 'InputNumber',
  },
  {
    label: '脚本描述',
    field: 'description',
    component: 'InputTextArea',
  },
  {
    label: '脚本代码内容',
    field: 'content',
    component: 'InputTextArea',
  },
  {
    label: '脚本图标',
    field: 'icon',
    component: 'Input',
  },
  {
    label: '脚本颜色',
    field: 'color',
    component: 'Input',
  },
  {
    label: '脚本状态',
    field: 'status',
    component: 'Input',
  },
  {
    label: '支持系统(JSON数组)',
    field: 'systems',
    component: 'Input',
  },
  {
    label: '功能特性(JSON数组)',
    field: 'features',
    component: 'Input',
  },
  {
    label: '技术栈(JSON数组)',
    field: 'techStack',
    component: 'Input',
  },
  {
    label: '下载次数',
    field: 'downloadCount',
    component: 'InputNumber',
  },
  {
    label: '查看次数',
    field: 'viewCount',
    component: 'InputNumber',
  },
  {
    label: '排序权重',
    field: 'sortOrder',
    component: 'InputNumber',
  },
  {
    label: '创建人',
    field: 'createdBy',
    component: 'Input',
  },
  {
    label: '创建时间',
    field: 'createdTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '更新人',
    field: 'updatedBy',
    component: 'Input',
  },
  {
    label: '更新时间',
    field: 'updatedTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '是否删除(0:否,1:是)',
    field: 'deleted',
    component: 'InputNumber',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '脚本名称', order: 0, view: 'text', type: 'string' },
  fileName: { title: '文件名', order: 1, view: 'text', type: 'string' },
  fileSize: { title: '文件大小(字节)', order: 2, view: 'number', type: 'number' },
  description: { title: '脚本描述', order: 3, view: 'textarea', type: 'string' },
  content: { title: '脚本代码内容', order: 4, view: 'textarea', type: 'string' },
  icon: { title: '脚本图标', order: 5, view: 'text', type: 'string' },
  color: { title: '脚本颜色', order: 6, view: 'text', type: 'string' },
  status: { title: '脚本状态', order: 7, view: 'text', type: 'string' },
  systems: { title: '支持系统(JSON数组)', order: 8, view: 'text', type: 'string' },
  features: { title: '功能特性(JSON数组)', order: 9, view: 'text', type: 'string' },
  techStack: { title: '技术栈(JSON数组)', order: 10, view: 'text', type: 'string' },
  downloadCount: { title: '下载次数', order: 11, view: 'number', type: 'number' },
  viewCount: { title: '查看次数', order: 12, view: 'number', type: 'number' },
  sortOrder: { title: '排序权重', order: 13, view: 'number', type: 'number' },
  createdBy: { title: '创建人', order: 14, view: 'text', type: 'string' },
  createdTime: { title: '创建时间', order: 15, view: 'datetime', type: 'string' },
  updatedBy: { title: '更新人', order: 16, view: 'text', type: 'string' },
  updatedTime: { title: '更新时间', order: 17, view: 'datetime', type: 'string' },
  deleted: { title: '是否删除(0:否,1:是)', order: 18, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
